
import LoadingController from "../../game/loading/LoadingController";
import LoginInterface from "../base/LoginInterface";
import GameProxy from "../../proxy/GameProxy";
import Protocals from "../../proxy/Protocals";
import ReceiveMessage from "../../framework/net/message/ReceiveMessage";
import UserModel from "../../game/logic/user/UserModel";
import { LOGIN_ACCOUNT } from "../../game/config/Const";

export default class DevLogin implements LoginInterface {
    constructor(){
        GameProxy.getInstance().addEventListener(Protocals.LOGIN,this.onLogin,this);
    }
    
    login(){
        GameProxy.getInstance().sendMessage(Protocals.LOGIN,{account:LOGIN_ACCOUNT});
        
    }

    onLogin(msg:ReceiveMessage){
        if(!msg.isError()){
            UserModel.getInstance().initData(msg.getData());
            LoadingController.instance().intoLayer();
        }
    }


    logout(){

    }

}
